home *** CD-ROM | disk | FTP | other *** search
/ PC Open 107 / PC Open 107 CD 1.bin / CD1 / INTERNET / COPIA SITI / HTTrack / httrack.exe / {app} / src_win / WinHTTrack / WinHTTrack.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2004-12-10  |  21.4 KB  |  871 lines

  1. // WinHTTrack.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "WinHTTrack.h"
  6.  
  7. #include "Shell.h"
  8. #include "winsock.h"
  9.  
  10. #include "wid1.h"
  11. #include "maintab.h"
  12.  
  13. #include "MainFrm.h"
  14. #include "splitter.h"
  15. #include "about.h"
  16.  
  17. #include "WinHTTrackDoc.h"
  18. #include "WinHTTrackView.h"
  19.  
  20. #include "inprogress.h"
  21.  
  22. /* HTS - HTTRACK */
  23. extern "C" {
  24.   #include "HTTrackInterface.h"
  25.   #include "htsbase.h"
  26.   #include "htsglobal.h"
  27.   #include "htsthread.h"
  28. };
  29.  
  30. #ifdef _DEBUG
  31. #define new DEBUG_NEW
  32. #undef THIS_FILE
  33. static char THIS_FILE[] = __FILE__;
  34. #endif
  35.  
  36. //
  37. #include "DialogContainer.h"
  38. #include "InfoUrl.h"
  39.  
  40. // PAS de domodal a l'exterieur!!!!!
  41. #include "wizard.h"
  42. #include "wizard2.h"
  43. #include "WizLinks.h"
  44. extern char WIZ_question[1000];
  45. extern char WIZ_reponse[1000];
  46.  
  47.  
  48. extern Wid1* dialog1;
  49. extern CMainTab* maintab;
  50. extern Cinprogress* inprogress;
  51. extern CShellApp* CShellApp_app;
  52. extern int termine;
  53. extern int termine_requested;
  54. extern int soft_term_requested;
  55. extern int shell_terminated;
  56. extern CInfoUrl* _Cinprogress_inst;
  57. extern int LibRasUse;
  58.  
  59. /*extern "C" {
  60.   char* hts_rootdir(char* file);
  61. };*/
  62.  
  63.  
  64. // rmdir
  65. #include <direct.h>
  66.  
  67. // linput
  68. /*extern "C" {
  69.   void linput(FILE* fp,char* s,int max);
  70.   void linput_trim(FILE* fp,char* s,int max);
  71.   void linput_cpp(FILE* fp,char* s,int max);
  72. };*/
  73.  
  74. /* WinHTTrack refresh Mutex */
  75. HANDLE WhttMutex;
  76.  
  77. /* Location */
  78. char* WhttLocation="";
  79.  
  80.  
  81. // HTTrack main vars
  82. HWND App_Main_HWND;
  83. CSplitterFrame* this_CSplitterFrame=NULL;
  84. HICON httrack_icon;
  85. // Helper
  86. LaunchHelp* HtsHelper=NULL;
  87.  
  88. // dirtreeview
  89. #include "DirTreeView.h"
  90. extern CDirTreeView* this_DirTreeView;
  91.  
  92. // New Project
  93. #include "NewProj.h"
  94. extern CNewProj* dialog0;
  95.  
  96.  
  97. // InfoEnd
  98. #include "infoend.h"
  99. extern Cinfoend* this_Cinfoend;
  100.  
  101. // Pointeur sur nous
  102. CWinHTTrackApp* this_app=NULL;
  103.  
  104. // fexist
  105. extern "C" int fexist(char*);
  106.  
  107. /////////////////////////////////////////////////////////////////////////////
  108. // CWinHTTrackApp
  109.  
  110. BEGIN_MESSAGE_MAP(CWinHTTrackApp, CWinApp)
  111.     //{{AFX_MSG_MAP(CWinHTTrackApp)
  112.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  113.     ON_COMMAND(ID_FILE_SAVE, OnFileSave)
  114.     ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
  115.     ON_COMMAND(ID_FILE_MRU_FILE1, OnFileMruFile1)
  116.     //}}AFX_MSG_MAP
  117.   ON_COMMAND(wm_ViewRestart,OnViewRestart)
  118.   ON_COMMAND(wm_WizRequest1,OnWizRequest1)
  119.   ON_COMMAND(wm_WizRequest2,OnWizRequest2)
  120.   ON_COMMAND(wm_WizRequest3,OnWizRequest3)
  121.     // Standard file based document commands
  122.     //ON_COMMAND(ID_FILE_WIZARD, OnWizard)
  123.     ON_COMMAND(ID_FILE_NEW, OnFileNew)
  124.     ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  125.     ON_COMMAND(ID_FILE_DELETE_PROJ, OnFileDelete)
  126.     ON_COMMAND(ID_FILE_BROWSE_SIT, OnBrowseWebsites)
  127.   ON_COMMAND(IDC_langprefs,Onipabout)
  128.   ON_COMMAND(ID_ABOUT,Onipabout)
  129.   ON_COMMAND(ID_UPDATE,OnUpdate)
  130.     ON_COMMAND(ID_HELP_FINDER,OnHelpInfo2)
  131.     ON_COMMAND(ID_HELP,OnHelpInfo2)
  132.     //ON_COMMAND(ID_CONTEXT_HELP,OnContextHelp)
  133.     ON_COMMAND(ID_DEFAULT_HELP,OnHelpInfo2)
  134.   // Forward to inprogress
  135.   ON_BN_CLICKED(ID_LOAD_OPTIONS,FwOnLoadprofile)
  136.   ON_BN_CLICKED(ID_FILE_SAVE_OPTIONS_AS,FwOnSaveprofile)
  137.     ON_BN_CLICKED(ID_LoadDefaultOptions, FwOnLoaddefault)
  138.     ON_BN_CLICKED(ID_SaveDefaultOptions, FwOnSavedefault)
  139.     ON_BN_CLICKED(ID_ClearDefaultOptions,FwOnResetdefault)
  140.   //
  141.   ON_BN_CLICKED(ID_WINDOW_HIDE,FwOnhide)
  142.   //
  143.     ON_BN_CLICKED(ID_OPTIONS_MODIFY,FwOnModifyOpt)
  144.     ON_BN_CLICKED(ID_FILE_PAUSE,FwOnPause)
  145.     ON_BN_CLICKED(ID_LOG_VIEWLOG,FwOniplogLog)
  146.     ON_BN_CLICKED(ID_LOG_VIEWERRORLOG,FwOniplogErr)
  147.     ON_BN_CLICKED(ID_LOG_VIEWTRANSFERS,FwOnViewTransfers)
  148. END_MESSAGE_MAP()
  149.  
  150. /////////////////////////////////////////////////////////////////////////////
  151. // CWinHTTrackApp construction
  152.  
  153. CWinHTTrackApp::CWinHTTrackApp()
  154. {
  155.   // HTTrack inits
  156.   CreateMutex(NULL, FALSE, "WinHTTrack_RUN");
  157.   HtsHelper = new LaunchHelp();
  158. }
  159.  
  160. CWinHTTrackApp::~CWinHTTrackApp()
  161. {
  162.   DeleteTabs();
  163.   delete HtsHelper;
  164.   HtsHelper=NULL;
  165. }
  166.  
  167. /////////////////////////////////////////////////////////////////////////////
  168. // The one and only CWinHTTrackApp object
  169.  
  170. CWinHTTrackApp theApp;
  171.  
  172. /////////////////////////////////////////////////////////////////////////////
  173. // CWinHTTrackApp initialization
  174.  
  175. void InitCBErrMsg(char* msg, char* file, int line) {
  176.   CString st;
  177.   st.Format("A fatal error has occured\r\n%s"
  178.     "\r\nin file '%s', line %d\r\n"
  179.     "Please report the problem at http://forum.httrack.com\r\n"
  180.     "using the CRASH.TXT file generated in the WinHTTrack directory\r\n"
  181.     "Thank you!", msg, file, line);
  182.   AfxMessageBox(st, MB_OK|MB_APPLMODAL|MB_SYSTEMMODAL|MB_ICONSTOP);
  183. }
  184. void InitCBErr() {
  185.   htsCallbackErr = InitCBErrMsg;
  186. }
  187.  
  188. int Eval_Exception( void );
  189.  
  190. int Eval_Exception ( int n_except )
  191. {
  192.     AfxMessageBox("error");
  193.  
  194.     return 0;
  195. }
  196.  
  197. /*extern "C" {
  198.   int hts_init(void);
  199.   void hts_uninit(void);
  200. }*/
  201.  
  202. #include "mmsystem.h"
  203.  
  204. BOOL CWinHTTrackApp::InitInstance()
  205. {
  206.   /* No error messageboxes */
  207.   SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | SEM_NOGPFAULTERRORBOX);
  208.  
  209.   /* Inits */
  210.   InitCBErr();
  211.   hts_init();
  212.  
  213.   WhttMutex = CreateMutex(NULL,FALSE,NULL);
  214.  
  215.   // Change the registry key under which our settings are stored.
  216.   // TODO: You should modify this string to be something appropriate
  217.   // such as the name of your company or organization.
  218.   SetRegistryKey("WinHTTrack Website Copier");
  219.   LANG_INIT();    // petite init langue
  220.   
  221.   /* INDISPENSABLE pour le drag&drop! */
  222.   InitCommonControls();
  223.   if (!AfxOleInit())
  224.   {
  225.       AfxMessageBox(LANG(LANG_F1));
  226.       return FALSE;
  227.   }
  228.   AfxEnableControlContainer();
  229.   
  230.   // Pointeur sur CShellApp
  231.   CShellApp_app=&app;
  232.   this_app=this;
  233.   _Cinprogress_inst=NULL;
  234.   LibRasUse=0;
  235.  
  236.     // Standard initialization
  237.     // If you are not using these features and wish to reduce the size
  238.     //  of your final executable, you should remove from the following
  239.     //  the specific initialization routines you do not need.
  240.  
  241.   httrack_icon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  242.  
  243.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  244.  
  245.     // Register the application's document templates.  Document templates
  246.     //  serve as the connection between documents, frame windows and views.
  247.  
  248.   // DOC //
  249.     CMultiDocTemplate* pDocTemplate;
  250.     pDocTemplate = new CMultiDocTemplate(
  251.         IDR_MAINFRAME,
  252.         RUNTIME_CLASS(CWinHTTrackDoc),
  253.         RUNTIME_CLASS(CSplitterFrame),       // main SDI frame window
  254.         RUNTIME_CLASS(CView)); 
  255.     AddDocTemplate(pDocTemplate);
  256.  
  257.   /*
  258.     CMDIFrameWnd* pMainFrame = new CMDIFrameWnd;
  259.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  260.         return FALSE;
  261.   */
  262.  
  263.     // create main window
  264.     CMainFrame* pMainFrame = new CMainFrame;
  265.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  266.         return FALSE;
  267.     m_pMainWnd = pMainFrame;
  268.     int nCmdShow = m_nCmdShow;
  269.  
  270.  
  271.   // Also in this example, there is only one menubar shared between
  272.     //  all the views.  The automatic menu enabling support of MFC
  273.     //  will disable the menu items that don't apply based on the
  274.     //  currently active view.  The one MenuBar is used for all
  275.     //  document types, including when there are no open documents.
  276.  
  277.   // enable file manager drag/drop and DDE Execute open
  278.     pMainFrame->DragAcceptFiles();
  279.  
  280.   // Now finally show the main menu
  281.     //pMainFrame->ShowWindow(m_nCmdShow);
  282.     //pMainFrame->UpdateWindow();
  283.     m_pMainWnd = pMainFrame;
  284.  
  285.   // command line arguments are ignored, create a new (empty) document
  286.     //OnFileNew();
  287.   // DOC //
  288.  
  289.     // Parse command line for standard shell commands, DDE, file open
  290.     CCommandLineInfo cmdInfo;
  291.     ParseCommandLine(cmdInfo);
  292.  
  293.   hts_rootdir((char*)AfxGetApp()->m_pszHelpFilePath);
  294.  
  295.   // Restore position
  296.     ((CMainFrame*)m_pMainWnd)->InitialShowWindow(nCmdShow);
  297.     pMainFrame->UpdateWindow();
  298.  
  299.     // Dispatch commands specified on the command line
  300.     if (!ProcessShellCommand(cmdInfo))
  301.         return FALSE;
  302.  
  303.   // Init Winsock
  304.   WSockInit();
  305.  
  306.     // The one and only window has been initialized, so show and update it.
  307.     //m_pMainWnd->ShowWindow(SW_SHOW);
  308.     //m_pMainWnd->UpdateWindow();
  309.  
  310.   /*CWinApp* app=AfxGetApp();
  311.   POSITION pos;
  312.   pos=app->GetFirstDocTemplatePosition();
  313.   CDocTemplate* templ = app->GetNextDocTemplate(pos);
  314.   pos=templ->GetFirstDocPosition();
  315.   CDocument* doc  = templ->GetNextDoc(pos);
  316.  
  317.   CRuntimeClass* pRuntimeClass = RUNTIME_CLASS( CTest );
  318.   CObject* pObject = pRuntimeClass->CreateObject();
  319.   ASSERT( pObject->IsKindOf( RUNTIME_CLASS( CTest ) ) );
  320.   
  321.   doc->AddView((CView*) pObject);
  322.   */
  323.  
  324.   {
  325.     // enable file manager drag/drop and DDE Execute open
  326.     EnableShellOpen();
  327.     RegisterShellFileTypes();
  328.     // register "New File" handler
  329.     HKEY phkResult;
  330.     DWORD creResult;
  331.     if (RegCreateKeyEx(HKEY_CLASSES_ROOT,".whtt",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&phkResult,&creResult)==ERROR_SUCCESS) {
  332.       RegCloseKey(phkResult);
  333.       if (RegCreateKeyEx(HKEY_CLASSES_ROOT,".whtt\\ShellNew",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&phkResult,&creResult)==ERROR_SUCCESS) {
  334.         char voidbuff='\0';
  335.         RegSetValueEx(phkResult,"NullFile",0,REG_SZ,(LPBYTE)&voidbuff,1);
  336.         RegCloseKey(phkResult);
  337.       }
  338.     }   
  339.  
  340.     // Infos la 1ere fois!
  341.     CWinApp* pApp = AfxGetApp();
  342.     if (pApp->GetProfileInt("Interface","FirstRun",0) != 3) {
  343.       pApp->WriteProfileInt("Interface","FirstRun",3);
  344.  
  345.       Cabout about;
  346.       about.DoModal();
  347.       
  348.       // Default proxy?
  349.       if (maintab) {
  350.         maintab->DefineDefaultProxy();
  351.         if (maintab->DoModal()!=IDCANCEL) {
  352.           // Default proxy values
  353.           CString strSection       = "OptionsValues";
  354.           MyWriteProfileString("",strSection, "Proxy",maintab->m_option10.m_proxy);
  355.           MyWriteProfileString("",strSection, "Port",maintab->m_option10.m_port);
  356.         }
  357.         maintab->UnDefineDefaultProxy();
  358.       }
  359.     }
  360.   }
  361.   
  362.  
  363. #ifdef HTTRACK_AFF_WARNING
  364. #ifndef _DEBUG
  365.   AfxMessageBox("--WARNING--\r\n"HTTRACK_AFF_WARNING);
  366. #endif
  367. #endif
  368.  
  369.   return TRUE;
  370. }
  371.  
  372.  
  373. BOOL CWinHTTrackApp::WSockInit() {
  374.   // Initialiser WINSOCK
  375.   WORD   wVersionRequested; /* requested version WinSock API */ 
  376.   WSADATA wsadata;        /* Windows Sockets API data */
  377.   {
  378.     int stat;
  379.     wVersionRequested = 0x0101;
  380.     stat = WSAStartup( wVersionRequested, &wsadata );
  381.     if (stat != 0) {
  382.       //HTS_PANIC_PRINTF("Winsock not found!\n");
  383.     } else if (LOBYTE(wsadata.wVersion) != 1  && HIBYTE(wsadata.wVersion) != 1) {
  384.       //HTS_PANIC_PRINTF("WINSOCK.DLL does not support version 1.1\n");
  385.       WSACleanup();
  386.     }
  387.   }
  388.   // Fin Initialiser WINSOCK
  389.   return TRUE;
  390. }
  391.  
  392. /////////////////////////////////////////////////////////////////////////////
  393. // CAboutDlg dialog used for App About
  394.  
  395. /*
  396. class CAboutDlg : public CDialog
  397. {
  398. public:
  399.     CAboutDlg();
  400.  
  401. // Dialog Data
  402.     //{{AFX_DATA(CAboutDlg)
  403.     enum { IDD = IDD_ABOUTBOX };
  404.     //}}AFX_DATA
  405.  
  406.     // ClassWizard generated virtual function overrides
  407.     //{{AFX_VIRTUAL(CAboutDlg)
  408.     protected:
  409.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  410.     //}}AFX_VIRTUAL
  411.  
  412. // Implementation
  413. protected:
  414.     //{{AFX_MSG(CAboutDlg)
  415.         // No message handlers
  416.     //}}AFX_MSG
  417.     DECLARE_MESSAGE_MAP()
  418. };
  419.  
  420. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  421. {
  422.     //{{AFX_DATA_INIT(CAboutDlg)
  423.     //}}AFX_DATA_INIT
  424. }
  425.  
  426. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  427. {
  428.     CDialog::DoDataExchange(pDX);
  429.     //{{AFX_DATA_MAP(CAboutDlg)
  430.     //}}AFX_DATA_MAP
  431. }
  432.  
  433. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  434.     //{{AFX_MSG_MAP(CAboutDlg)
  435.         // No message handlers
  436.     //}}AFX_MSG_MAP
  437. END_MESSAGE_MAP()
  438. */
  439.  
  440. // App command to run the dialog
  441. void CWinHTTrackApp::OnAppAbout()
  442. {
  443.   Cabout about;
  444.   about.DoModal();
  445. //    CAboutDlg aboutDlg;
  446. //    aboutDlg.DoModal();
  447. }
  448.  
  449.  
  450. /* Request: Set new view in the splitter window (when clicking on finished, for example) */
  451. /*extern "C" {
  452.   int hts_resetvar(void);
  453. }*/
  454.  
  455. void CWinHTTrackApp::OnViewRestart() {
  456.   //CloseAllDocuments(FALSE);
  457.   //OnFileNew();
  458.  
  459.   /* Free library */
  460.   WHTT_LOCK();
  461.   hts_resetvar();
  462.   WHTT_UNLOCK();
  463.  
  464.   this_CSplitterFrame->SetNewView(0,1,RUNTIME_CLASS(CDialogContainer));
  465. }
  466.  
  467. void CWinHTTrackApp::OnWizRequest1() {
  468.   wizard diawiz;
  469.   diawiz.m_question=WIZ_question;
  470.   diawiz.DoModal();
  471.   strcpybuff(WIZ_reponse,diawiz.m_reponse);
  472. }
  473.  
  474. void CWinHTTrackApp::OnWizRequest2() {
  475.   wizard2 diawiz2;
  476.   diawiz2.m_question=WIZ_question;
  477.   if (diawiz2.DoModal()==IDOK)
  478.   strcpybuff(WIZ_reponse,"YES");
  479.   else
  480.     strcpybuff(WIZ_reponse,"NO");
  481. }
  482.  
  483. void CWinHTTrackApp::OnWizRequest3() {
  484.   WizLinks diawiz3;
  485.   diawiz3.m_url=WIZ_question;
  486.   if (diawiz3.DoModal()==IDskipall)
  487.     strcpybuff(WIZ_reponse,"*");
  488.   else
  489.     switch(diawiz3.m_lnk) {
  490.     case 0:
  491.       strcpybuff(WIZ_reponse,"0");
  492.       break;
  493.     case 1:
  494.       strcpybuff(WIZ_reponse,"1");
  495.       break;
  496.     case 2:
  497.       strcpybuff(WIZ_reponse,"2");
  498.       break;
  499.     case 3:
  500.       strcpybuff(WIZ_reponse,"4");
  501.       break;
  502.     case 4:
  503.       strcpybuff(WIZ_reponse,"5");
  504.       break;
  505.     case 5:
  506.       strcpybuff(WIZ_reponse,"6");
  507.       break;
  508.     default:
  509.       strcpybuff(WIZ_reponse,"");
  510.       break;
  511.   }
  512. }
  513.  
  514.  
  515. //
  516.  
  517.  
  518. /////////////////////////////////////////////////////////////////////////////
  519. // CWinHTTrackApp message handlers
  520.  
  521. // Ne fait pas partie de la classe
  522. /*
  523. UINT RunBackEngine( LPVOID pP ) {
  524.   static int running=0;
  525.   if (running)
  526.     return 0;
  527.   running=1;
  528.   {
  529.     CWinApp* app=AfxGetApp();
  530.     POSITION pos;
  531.     pos=app->GetFirstDocTemplatePosition();
  532.     CDocTemplate* templ = app->GetNextDocTemplate(pos);
  533.     pos=templ->GetFirstDocPosition();
  534.     CDocument* doc  = templ->GetNextDoc(pos);
  535.     pos=doc->GetFirstViewPosition();
  536.     CView*     view = doc->GetNextView(pos);
  537.     App_Main_HWND=view->m_hWnd;
  538.   }
  539.   //
  540.   CShellApp app;
  541.   app.InitInstance();
  542.   running=0;
  543.   return 0;
  544. }
  545. */
  546.  
  547. /*
  548. void CWinHTTrackApp::OnWizard() {
  549.   //this_CSplitterFrame->SetNewView(0,1,RUNTIME_CLASS(CDialogContainer));
  550. }
  551. */
  552.  
  553. afx_msg void CWinHTTrackApp::OnFileNew( ) {
  554.   OpenDocumentFile("");
  555. }
  556.  
  557. afx_msg void CWinHTTrackApp::OnFileOpen( ) {
  558.   this->CWinApp::OnFileOpen();
  559. }
  560.  
  561. void CWinHTTrackApp::OnFileSave() {
  562. }
  563.  
  564. void CWinHTTrackApp::OnFileSaveAs() 
  565. {
  566.     // TODO: Add your command handler code here
  567.     
  568. }
  569.  
  570. void CWinHTTrackApp::OnFileDelete()
  571. {
  572.   static char szFilter[256];
  573.   strcpybuff(szFilter,"WinHTTrack Website Copier Project (*.whtt)|*.whtt||");
  574.   CFileDialog* dial = new CFileDialog(true,"whtt",NULL,OFN_HIDEREADONLY,szFilter);
  575.   if (dial->DoModal() == IDOK) {
  576.     CString st=dial->GetPathName();
  577.     if (fexist((char*) LPCTSTR(st))) {
  578.       int pos=st.ReverseFind('.');
  579.       CString dir=st.Left(pos)+"\\";
  580.       char msg[1000];
  581.       sprintf(msg,"%s\r\n%s",LANG_DELETECONF,dir);
  582.       if (AfxMessageBox(msg,MB_OKCANCEL)==IDOK) {
  583.         if (remove(st)) {
  584.           AfxMessageBox("Error deleting "+st);
  585.         } else {
  586.           RmDir(dir);
  587.         }
  588.       }
  589.     } else
  590.       AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/));
  591.   }
  592.   delete dial;
  593. }
  594.  
  595. void CWinHTTrackApp::OnBrowseWebsites()
  596. {
  597.   CString st=dialog0->GetBasePath();
  598.  
  599.   if (st.GetLength()<=1) {
  600.     CString strSection       = "DefaultValues";    
  601.     CWinApp* pApp = AfxGetApp();
  602.     st = pApp->GetProfileString(strSection, "BasePath");
  603.     st += "\\";
  604.   }
  605.  
  606.   st+="index.html";
  607.   ShellExecute(NULL,"open",st,"","",SW_RESTORE);    
  608. }
  609.  
  610. BOOL CWinHTTrackApp::RmDir(CString srcpath) {
  611.   CWaitCursor wait;
  612.  
  613.   if (srcpath.GetLength()==0)
  614.     return FALSE;
  615.   CString path=srcpath;
  616.   WIN32_FIND_DATA find;
  617.   if (path.Right(1)!="\\")
  618.     path+="\\";  
  619.   HANDLE h = FindFirstFile(path+"*.*",&find);
  620.   if (h != INVALID_HANDLE_VALUE) {
  621.     do {
  622.       if (!(find.dwFileAttributes  & FILE_ATTRIBUTE_SYSTEM ))
  623.       if (strcmp(find.cFileName,".."))
  624.       if (strcmp(find.cFileName,"."))
  625.         if (!(find.dwFileAttributes  & FILE_ATTRIBUTE_DIRECTORY )) {
  626.           if (remove(path+find.cFileName)) {
  627.             AfxMessageBox("Error deleting "+path+find.cFileName);
  628.             return FALSE;
  629.           }
  630.         } else {
  631.           if (!RmDir(path+find.cFileName))
  632.             return FALSE;
  633.         }
  634.     } while(FindNextFile(h,&find));
  635.     FindClose(h);
  636.   }
  637.   if (rmdir(srcpath)) {
  638.     AfxMessageBox("Error deleting "+srcpath);
  639.     return FALSE;
  640.   }
  641.   return TRUE;
  642. }
  643.  
  644.  
  645. void CWinHTTrackApp::OnFileMruFile1() 
  646. {
  647.     // TODO: Add your command handler code here
  648.     
  649. }
  650.  
  651. void CWinHTTrackApp::Onipabout() 
  652. {
  653.   Cabout about;
  654.   about.DoModal();
  655. }
  656.  
  657. void CWinHTTrackApp::OnUpdate() 
  658. {
  659.   CString st;
  660.   st.Format(HTS_UPDATE_WEBSITE,HTS_PLATFORM,LANGUAGE_NAME);
  661.   HtsHelper->Help(st);
  662. }
  663.  
  664. // Appel aide
  665. void CWinHTTrackApp::OnHelpInfo2() {
  666.   (void) OnHelpInfo(NULL);
  667. }
  668.  
  669. BOOL CWinHTTrackApp::OnHelpInfo(HELPINFO* dummy) 
  670. {
  671.   HtsHelper->Help("step2.html");
  672.   return true;
  673. }
  674.  
  675. // Forwards
  676.  
  677. void CWinHTTrackApp::FwOnhide() {
  678.   if (this_CSplitterFrame)
  679.     this_CSplitterFrame->Onhide();
  680.   else
  681.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  682. }
  683.  
  684. void CWinHTTrackApp::FwOnLoadprofile() {
  685.   if ((dialog1!=NULL) && (maintab!=NULL))
  686.     dialog1->OnLoadprofile();
  687.   else
  688.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  689. }
  690. void CWinHTTrackApp::FwOnSaveprofile() {
  691.   if ((dialog1!=NULL) && (maintab!=NULL))
  692.     dialog1->OnSaveprofile();
  693.   else
  694.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  695. }
  696. void CWinHTTrackApp::FwOnLoaddefault() {
  697.   if ((dialog1!=NULL) && (maintab!=NULL))
  698.     dialog1->OnLoaddefault();
  699.   else
  700.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  701. }
  702. void CWinHTTrackApp::FwOnSavedefault() {
  703.   if ((dialog1!=NULL) && (maintab!=NULL))
  704.     dialog1->OnSavedefault();
  705.   else
  706.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  707. }
  708. void CWinHTTrackApp::FwOnResetdefault() {
  709.   if ((dialog1!=NULL) && (maintab!=NULL))
  710.     dialog1->OnResetdefault();
  711.   else
  712.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  713. }
  714.  
  715. //
  716.  
  717. void CWinHTTrackApp::FwOnModifyOpt() {
  718.   if ((inprogress!=NULL) && (maintab!=NULL))
  719.     inprogress->OnModifyOpt();
  720.   else
  721.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  722. }
  723.  
  724. void CWinHTTrackApp::FwOnPause() {
  725.   if ((inprogress!=NULL) && (maintab!=NULL))
  726.     inprogress->OnPause();
  727.   else
  728.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  729. }
  730.  
  731. void CWinHTTrackApp::FwOniplogLog() {
  732.   if ((inprogress!=NULL) && (maintab!=NULL))
  733.     inprogress->OniplogLog();
  734.   else
  735.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  736. }
  737.  
  738. void CWinHTTrackApp::FwOniplogErr() {
  739.   if ((inprogress!=NULL) && (maintab!=NULL))
  740.     inprogress->OniplogErr();
  741.   else
  742.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  743. }
  744.  
  745. void CWinHTTrackApp::FwOnViewTransfers() {
  746.   if ((inprogress!=NULL) && (maintab!=NULL))
  747.     inprogress->OnViewTransfers();
  748.   else
  749.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  750. }
  751.  
  752. CDocument* CWinHTTrackApp::OpenDocumentFile( LPCTSTR lpszFileName)
  753. {
  754.   // Eviter deux fenΩtres (un seul document)
  755.   // Le CMultui..->CSingleDoc.. est trop complexe α changer (α cause du splitter-wnd)
  756.   int count=1;
  757.  
  758.   { /* Check if a document exists, and if exists if empty or not, and if name is different */
  759.     POSITION pos;
  760.     pos=GetFirstDocTemplatePosition();
  761.     if (pos) {
  762.       CDocTemplate* tmpl=GetNextDocTemplate(pos);
  763.       if (tmpl) {
  764.         pos=tmpl->GetFirstDocPosition();
  765.         if (pos) {
  766.           CDocument* doc  = tmpl->GetNextDoc(pos);
  767.           if (doc) {
  768.             if (dialog0->GetName().GetLength()==0) {
  769.               CloseAllDocuments(FALSE);
  770.               count=0;        /* No documents */
  771.             } else {
  772.               if (dialog0->GetPath0()+".whtt" == LPCSTR(lpszFileName))
  773.                 return NULL;
  774.             }
  775.           }
  776.         } else
  777.           count=0;          /* No documents */
  778.       }
  779.     }
  780.   }
  781.  
  782.   // Ouvrir nouvelle instance
  783.   if (count) {
  784.     char cmdl[2048];
  785.     CWinApp* pApp = AfxGetApp();
  786.     CString name = pApp->m_pszHelpFilePath;
  787.     name=name.Left(name.GetLength()-4);
  788.     name += ".EXE";
  789.     strcpybuff(cmdl,"\"");
  790.     strcatbuff(cmdl,lpszFileName);
  791.     strcatbuff(cmdl,"\"");
  792.     ShellExecute(NULL,"open",name,cmdl,"",SW_RESTORE);
  793.     return NULL;
  794.   }
  795.  
  796.   // Ouvrir nouveau?
  797.   //if (count)
  798.   //  return;       // ne rien faire, car limitΘ α 1 document
  799.   //count++;
  800.  
  801.   /* Ouvrir */
  802.   /*
  803.   CWinApp* app=AfxGetApp();
  804.   POSITION pos;
  805.   pos=app->GetFirstDocTemplatePosition();
  806.   CDocTemplate* templ = app->GetNextDocTemplate(pos);
  807.   pos=templ->GetFirstDocPosition();
  808.   if (pos) {
  809.     CDocument* doc  = templ->GetNextDoc(pos);
  810.     if (doc)
  811.       if (!doc->SaveModified())
  812.         return NULL;
  813.   }
  814.   CloseAllDocuments(FALSE);
  815.   */
  816.   if (strlen(lpszFileName))
  817.     return CWinApp::OpenDocumentFile(lpszFileName);
  818.   else
  819.     CWinApp::OnFileNew();
  820.   return NULL;
  821. }
  822.  
  823. void CWinHTTrackApp::NewTabs() {
  824.   DeleteTabs();
  825.   m_tab0 = new CFirstInfo();
  826.   m_tab1 = new CNewProj();
  827.   m_tab2 = new Wid1();
  828.   m_tab3 = new Ctrans();
  829.   m_tabprogress = new Cinprogress();
  830.   m_tabend = new Cinfoend();
  831. }
  832.  
  833. void CWinHTTrackApp::DeleteTabs() {
  834.   if (m_tab0)
  835.   if (m_tab0->GetSafeHwnd())       /* a dΘja ΘtΘ dΘtruit par CWinApp */
  836.     delete m_tab0;
  837.   if (m_tab1)
  838.   if (m_tab1->GetSafeHwnd())
  839.     delete m_tab1;
  840.   if (m_tab2)
  841.   if (m_tab2->GetSafeHwnd())
  842.     delete m_tab2;
  843.   if (m_tab3)
  844.   if (m_tab3->GetSafeHwnd())
  845.     delete m_tab3;
  846.   if (m_tabprogress)
  847.   if (m_tabprogress->GetSafeHwnd())
  848.     delete m_tabprogress;
  849.   if (m_tabend)
  850.   if (m_tabend->GetSafeHwnd())
  851.     delete m_tabend;
  852.  
  853.   m_tab0=NULL;
  854.   m_tab1=NULL;
  855.   m_tab2=NULL;
  856.   m_tab3=NULL;
  857.   m_tabprogress=NULL;
  858.   m_tabend=NULL;
  859. }
  860.  
  861. int CWinHTTrackApp::ExitInstance() 
  862. {
  863.   LANG_DELETE();
  864.  
  865.   /* Uninitialize */
  866.   htsthread_wait();
  867.   hts_uninit();
  868.  
  869.   return CWinApp::ExitInstance();
  870. }
  871.